﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HYCodeBase.WinForm.WinFormRemindSuit
{
	internal abstract class BaseControlTransFormer
	{
		internal System.Windows.Forms.Control ThisControl
		{
			get
			{
				return this.m_thisControl;
			}
			private set
			{
				this.m_thisControl = value;
			}
		}

		internal bool IfIsSpecalValueControl
		{
			get
			{
				return this.m_bIfIsSpecalValueControl;
			}
			private set
			{
				this.m_bIfIsSpecalValueControl = value;
			}
		}

		internal static string StrName
		{
			get
			{
				return BaseControlTransFormer.m_strName;
			}
			private set
			{
				BaseControlTransFormer.m_strName = value;
			}
		}

		internal BaseControlTransFormer(ControlPacker inputControl, bool ifIsSpecialValue)
		{
			this.ThisControl = inputControl.UseControl;
			this.m_thisControlPacker = inputControl;
			this.m_bIfIsSpecalValueControl = ifIsSpecialValue;
			this.m_lstStringUseAttributeName = new List<string>();
			this.m_lstStringUseAttributeName.Add(BaseControlTransFormer.StrName);
		}

		internal virtual ControlInformationBean GetControlInformationBean()
		{
			ControlInformationBean controlInformationBean = null;
			if (this.ThisControl is System.Windows.Forms.Form)
			{
				controlInformationBean = new FormInformationBean(this.ThisControl.Name);
			}
			else
			{
				controlInformationBean = new ControlInformationBean(this.ThisControl.Name);
			}
			foreach (string inputAttributeName in this.m_lstStringUseAttributeName)
			{
				IAttributeGeter useGeter = this.m_useAttributeFactory.GetUseGeter(this.m_thisControlPacker, inputAttributeName);
				if (useGeter != null)
				{
					AttributeInformationBean oneAttributeBean = useGeter.GetOneAttributeBean(this.ThisControl, inputAttributeName);
					if (oneAttributeBean != null)
					{
						controlInformationBean.AddOneAttribute(oneAttributeBean);
					}
				}
			}
			return controlInformationBean;
		}

		internal virtual bool SetControlInfromation(ControlInformationBean inputControlInformation)
		{
			bool flag = false;
			foreach (string text in this.m_lstStringUseAttributeName)
			{
				IAttributeSeter useSeter = this.m_useAttributeFactory.GetUseSeter(this.m_thisControlPacker, text);
				if (useSeter == null)
				{
					flag = flag;
				}
				else
				{
					AttributeInformationBean oneAttributeBeanByName = inputControlInformation.GetOneAttributeBeanByName(text);
					if (oneAttributeBeanByName != null)
					{
						flag |= useSeter.TrySetOneAttribute(ref this.m_thisControl, oneAttributeBeanByName);
					}
				}
			}
			return flag;
		}

		private static string m_strName = "Name";

		protected List<string> m_lstStringUseAttributeName;

		private System.Windows.Forms.Control m_thisControl;

		protected IAttributerGSFactory m_useAttributeFactory;

		private ControlPacker m_thisControlPacker;

		private bool m_bIfIsSpecalValueControl;
	}
}
